package com.freexiaoyu.freevideoplay;

import android.app.Activity;
import android.media.MediaCodec;
import android.media.MediaCodecInfo;
import android.media.MediaFormat;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;

import tv.danmaku.ijk.media.player.IjkMediaPlayer;
import tv.danmaku.ijk.media.widget.media.AndroidMediaController;
import tv.danmaku.ijk.media.widget.media.IjkVideoView;


public class VideoFFmpegThreeActivity extends Activity {

    IjkVideoView videoView;
    AndroidMediaController controller;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_video_ffmpeg_three);

        initializePlayer("udp://192.168.1.11:22001");
    }

    private void initializePlayer(String url) {


        IjkMediaPlayer.loadLibrariesOnce(null);
        IjkMediaPlayer.native_profileBegin("libijkplayer.so");
        videoView = findViewById(R.id.ijkPlayer);
        //控制器，可有可无
        controller = new AndroidMediaController(this, false);
        videoView.setMediaController(controller);
        videoView.setVideoURI(Uri.parse(url));
        videoView.start();
    }


    @Override
    protected void onStop() {
        super.onStop();
        try {
            videoView.pause();
        } catch (Exception e) {
        }
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        videoView.stopPlayback();
    }


}
